package Leetcode;

public class Leetcode_278 {
    public static int minimumBoxes(int n) {
        int cur = 1, i = 1, j = 1;
        while (n > cur) {
            n -= cur;
            i++;
            cur += i;
        }
        cur = 1;
        while (n > cur) {
            n -= cur;
            j++;
            cur++;
        }
        return (i - 1) * i / 2 + j;
    }

    public static void main(String[] args) {
        int n = 3;
        System.out.println(minimumBoxes(n));
    }
}
